# 作业先完成，再完美
# 问：重点掌握用户变量，练习变量的赋值和使用
# SET @yesterday = SUBDATE(CURRENT_DATE, 1);
# SET @yesterday = DATE_FORMAT(@yesterday, '%Y/%m/%d');
# SELECT @yesterday

# SET @amount = 0.4;
# SET @amount = CAST(@amount as DECIMAL(15, 2));
# SELECT @amount

# 问：学习存储过程能自行完整地写出一个函数
# 创建
# CREATE PROCEDURE state_student(n INT)
# BEGIN
# 	DECLARE m_time VARCHAR(191);
# 	SET m_time = DATE_FORMAT(SUBDATE(CURRENT_DATE, n), '%Y-%m-%d');
# 	SELECT class as 班级,
# 	COUNT(*) as 人数,
# 	SUM(isFinish_hw) as 完成人数,
# 	FORMAT(SUM(isFinish_hw)/COUNT(*), 2) as 作业完成率,
# 	MAX(isFinish_hw) as 最大值,
# 	MIN(isFinish_hw) as 最小值
# 	FROM student
# 	WHERE stat_time=m_time
# 	GROUP BY class;
# END

# 调用：CALL state_student(0)